package top.huxy.boot.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import top.huxy.boot.model.vo.user.VO_User;
import top.huxy.boot.service.VOUserService;
import top.huxy.boot.util.IPAddressUtils;

@Service
public class VOUserServiceImpl implements VOUserService {
    @Autowired
    private RedisTemplate<String, Object> redisTemplate;

    @Override
    public VO_User getVOUserByToken(String token) {
        String ip = IPAddressUtils.getRequestIp();
        Object o = redisTemplate.opsForHash().get(ip, token);
        if(o instanceof VO_User){
            return ((VO_User) o);
        }
        return null;
    }
}
